﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Abp.Authorization;
using shenghua.Authorization;
using shenghua.Basics.WebsiteInfos.Dto;

namespace shenghua.Basics.WebsiteInfos
{
    public class WebsiteInfoAppService : shenghuaAppServiceBase, IWebsiteInfoAppService
    {
        private readonly WebsiteInfoManager _websiteInfoManager;

        public WebsiteInfoAppService(
            WebsiteInfoManager websiteInfoManager)
        {
            _websiteInfoManager = websiteInfoManager;
        }

        [AbpAuthorize(PermissionNames.WebsiteInfoManagement)]
        public async Task SetWebsiteInfo(WebSiteInfoDto input)
        {
            var item = ObjectMapper.Map<WebsiteInfo>(input);
            await _websiteInfoManager.SetWebsiteInfo(item);
        }
        public async Task<WebSiteInfoDto> GetWebsiteInfo()
        {
            var item = _websiteInfoManager.GetWebsiteInfo();
            return ObjectMapper.Map<WebSiteInfoDto>(item);
        }

        [AbpAuthorize(PermissionNames.WebsiteInfoManagement)]
        public async Task SetCompanyInfo(CompanyInfoDto input)
        {
            var item = ObjectMapper.Map<CompanyInfo>(input);
            await _websiteInfoManager.SetCompanyInfo(item);
        }
        public async Task<CompanyInfoDto> GetcompanyInfo()
        {
            var item = _websiteInfoManager.GetCompanyInfo();
            return ObjectMapper.Map<CompanyInfoDto>(item);
        }

        [AbpAuthorize(PermissionNames.WebsiteInfoManagement)]
        public async Task SetUserAgreement(ContentDto input)
        {
            var item = new EasyContent();
            input.MapTo(item);
            await _websiteInfoManager.SetUserAgreement(item);
        }
        public async Task<ContentDto> GetUserAgreement()
        {
            return new ContentDto(_websiteInfoManager.GetUserAgreement());
        }

        [AbpAuthorize(PermissionNames.WebsiteInfoManagement)]
        public async Task SetContactUs(ContentDto input)
        {
            var item = new EasyContent();
            input.MapTo(item);
            await _websiteInfoManager.SetContactUs(item);
        }
        public async Task<ContentDto> GetContactUs()
        {
            return new ContentDto(_websiteInfoManager.GetContactUs());
        }

        [AbpAuthorize(PermissionNames.WebsiteInfoManagement)]
        public async Task SetAboutUs(ContentDto input)
        {
            var item = new EasyContent();
            input.MapTo(item);
            await _websiteInfoManager.SetAboutUs(item);
        }
        public async Task<ContentDto> GetAboutUs()
        {
            return new ContentDto(_websiteInfoManager.GetAboutUs());
        }

        [AbpAuthorize(PermissionNames.WebsiteInfoManagement)]
        public async Task SetCompanyProfile(ContentDto input)
        {
            var item = new EasyContent();
            input.MapTo(item);
            await _websiteInfoManager.SetCompanyProfile(item);
        }
        public async Task<ContentDto> GetCompanyProfile()
        {
            return new ContentDto(_websiteInfoManager.GetCompanyProfile());
        }

        [AbpAuthorize(PermissionNames.WebsiteInfoManagement)]
        public async Task SetCorporateCulture(ContentDto input)
        {
            var item = new EasyContent();
            input.MapTo(item);
            await _websiteInfoManager.SetCorporateCulture(item);
        }
        public async Task<ContentDto> GetCorporateCulture()
        {
            return new ContentDto(_websiteInfoManager.GetCorporateCulture());
        }

        [AbpAuthorize(PermissionNames.WebsiteInfoManagement)]
        public async Task SetHonor(ContentDto input)
        {
            var item = new EasyContent();
            input.MapTo(item);
            await _websiteInfoManager.SetHonor(item);
        }
        public async Task<ContentDto> GetHonor()
        {
            return new ContentDto(_websiteInfoManager.GetHonor());
        }

        [AbpAuthorize(PermissionNames.WebsiteInfoManagement)]
        public async Task SetUserNotice(ContentDto input)
        {
            var item = new EasyContent();
            input.MapTo(item);
            await _websiteInfoManager.SetUserNotice(item);
        }
        public async Task<ContentDto> GetUserNotice()
        {
            return new ContentDto(_websiteInfoManager.GetUserNotice());
        }

        [AbpAuthorize(PermissionNames.WebsiteInfoManagement)]
        public async Task SetAdvertisement(EasyPictureCollectionDto input)
        {
            var items = new List<EasyPicture>();
            foreach(var item in input.Items)
            {
                var temp = new EasyPicture();
                item.MapTo(temp);
                items.Add(temp);
            }
            await _websiteInfoManager.SetAdvertisement(items);
        }
        public List<EasyPictureDto> GetAdvertisement()
        {
            return _websiteInfoManager.GetAdvertisement().Select(r => new EasyPictureDto(r)).ToList();
        }

        [AbpAuthorize(PermissionNames.WebsiteInfoManagement)]
        public async Task SetFriendlyLink(EasyPictureCollectionDto input)
        {
            var items = new List<EasyPicture>();
            foreach (var item in input.Items)
            {
                var temp = new EasyPicture();
                item.MapTo(temp);
                items.Add(temp);
            }
            await _websiteInfoManager.SetFriendlyLink(items);
        }
        public List<EasyPictureDto> GetFriendlyLink()
        {
            return _websiteInfoManager.GetFriendlyLink().Select(r => new EasyPictureDto(r)).ToList();
        }

    }
}
